package 模拟;

import java.util.ArrayList;
import java.util.Arrays;

/**
 * @author 帅小伙
 * @date 2021/12/28
 * @description
 */
public class DemoJZ61扑克中的顺子 {


    public boolean IsContinuous(int [] numbers) {

        Arrays.sort(numbers);
        int z = 0;
        if(numbers[0]==0){
            z = 1;
        }
        for (int i = 1; i < numbers.length; i++) {
            if(numbers[i]==0) z ++;
            else{
                if(numbers[i-1]==0)continue;
                else{
                    if(numbers[i] == numbers[i-1]){
                        return false;
                    }
                    z -= (numbers[i] - numbers[i-1] - 1);
                    if(z < 0){
                        return false;
                    }
                }
            }

        }

        return true;
    }
}
